package com.skt.exception;

import lombok.Getter;

@Getter
public enum CartErrorCode implements ErrorCode {

    // ========== 通用购物车错误 (20xxx) ==========
    CART_OPERATION_FAILED(20001, "购物车操作失败"),
    CART_NOT_FOUND(20002, "购物车不存在"),
    CART_ALREADY_EXISTS(20003, "购物车已存在"),
    CART_ITEM_NOT_FOUND(20004, "购物车商品不存在"),
    CART_ACCESS_DENIED(20005, "无权操作该购物车"),
    CART_IS_EMPTY(20006, "购物车为空"),

    // ========== 加入购物车相关 (201xx) ==========
    ADD_TO_CART_FAILED(20101, "添加商品到购物车失败"),
    PRODUCT_NOT_FOUND(20102, "商品不存在"),
    PRODUCT_NOT_AVAILABLE(20103, "商品已下架或不可用"),
    INSUFFICIENT_STOCK(20104, "库存不足"),
    EXCEED_MAX_QUANTITY(20105, "超过最大购买数量"),
    INVALID_QUANTITY(20106, "商品数量无效"),
    PRODUCT_ALREADY_IN_CART(20107, "商品已在购物车中"),
    RENTAL_DAYS_INVALID(20108, "租赁天数无效"),
    START_DATE_INVALID(20109, "租赁开始日期无效"),
    PRICE_CHANGED(20110, "商品价格已变动，请确认"),

    // ========== 获取购物车相关 (202xx) ==========
    GET_CART_FAILED(20201, "获取购物车失败"),
    CART_DATA_CORRUPTED(20202, "购物车数据异常"),
    CART_ITEM_INVALID(20203, "购物车商品数据无效"),

    // ========== 删除购物车项相关 (203xx) ==========
    REMOVE_ITEM_FAILED(20301, "删除购物车商品失败"),
    ITEM_ALREADY_REMOVED(20302, "商品已从购物车中移除"),
    BATCH_REMOVE_FAILED(20303, "批量删除商品失败"),

    // ========== 库存相关 (204xx) ==========
    STOCK_LOCK_FAILED(20401, "库存锁定失败"),
    STOCK_ROLLBACK_FAILED(20402, "库存回滚失败"),
    CONCURRENT_STOCK_UPDATE(20403, "库存并发更新冲突"),

    // ========== 价格相关 (205xx) ==========
    PRICE_CALCULATION_FAILED(20501, "价格计算失败"),
    PRICE_SNAPSHOT_EXPIRED(20502, "价格快照已过期"),
    PROMOTION_EXPIRED(20503, "促销活动已结束"),
    INVALID_PRICE(20504, "价格无效"), // 新增

    // ========== 业务限制相关 (206xx) ==========
    CART_ITEM_LIMIT_EXCEEDED(20601, "购物车商品数量超限"),
    SINGLE_PRODUCT_LIMIT_EXCEEDED(20602, "单商品购买数量超限"),
    TOTAL_AMOUNT_LIMIT_EXCEEDED(20603, "购物车总金额超限"),
    MERCHANT_RESTRICTION(20604, "商家限制购买"),

    // ========== 并发操作相关 (207xx) ==========
    CART_CONCURRENT_UPDATE(20701, "购物车正在被修改，请稍后重试"),
    CART_LOCK_ACQUIRE_FAILED(20702, "系统繁忙，请稍后重试"),
    OPERATION_FREQUENT(20703, "操作过于频繁，请稍后重试"),

    // ========== 缓存相关 (208xx) ==========
    CART_CACHE_FAILED(20801, "购物车缓存操作失败"),
    CART_CACHE_INCONSISTENT(20802, "购物车缓存数据不一致"),

    // ========== 数据验证相关 (209xx) ==========
    INVALID_CART_REQUEST(20901, "购物车请求参数无效"),
    INVALID_PRODUCT_INFO(20902, "商品信息无效"),
    INVALID_MERCHANT_INFO(20903, "商家信息无效"),
    DATE_VALIDATION_FAILED(20904, "日期验证失败");

    private final int code;
    private final String message;

    CartErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}